import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export default new Vuex.Store({
    state: {
        rection: 'forward',
        tokenKey: localStorage.getItem('tokenKey') || '',
        userInfo: JSON.parse(localStorage.getItem('userInfo')) || {} ,
        roles: JSON.parse(localStorage.getItem('roles')) || {} ,
        weather: {},
        sourceData:[] // 类比源
    },
    mutations: {
        updateDirection(state, direction) {
            state.direction = direction
        },
        updateTokenKey(state, direction) {
            state.tokenKey = direction;
            localStorage.setItem('tokenKey', direction);
        },
        upRealMeteorological(state, data) {
            state.tokenKey = data;
            localStorage.setItem('upRealMeteorological', data);
        },
        userInfo(state, data) {
            state.userInfo = JSON.parse(data);
            localStorage.setItem('userInfo', data);
        },
        roles(state, data) {
            state.roles = JSON.parse(data);
            localStorage.setItem('roles', data);
        },
        sourceData(state, data) {
            state.sourceData = data;
            localStorage.setItem('sourceData', data);
        },
        weather(state, data) {
            state.weather = data;
            localStorage.setItem('weather', data);
        },

    },
    actions: {
    }
})
